# coding:utf-8
from scrapy import cmdline
# from crawler.core.service_owner import *


# https://github.com/scrapy/scrapy/blob/master/scrapy/commands/crawl.py
# COMMANDS_MODULE = ''

cmdline.execute("scrapy crawl chuzu.owner.58.detail_out".split())



###### make some test ######

# import re
# baseinfo = 'xx'
# res = re.findall(r'(\d+)室(\d+)厅(\d+)卫|(\d+)室(\d+)厅', baseinfo)
# print ()


###### update some test ######

# service = BaseService()
# try:
#     select_sql = """select
#                       id, city_code, district_belong
#                     from
#                       crawler_chuzu_owner
#                     WHERE
#                       updated_time is NOT NULL and district_code is NULL
#                     ORDER BY
#                       created_time DESC
#                 """
#
#     houses = service.sql_conn.get_all(select_sql)
#     print('count: {0}'.format(len(houses)))
#     c = 0
#     for h in houses:
#         district_code = service.get_code('district', h[2], sub_str=h[1])
#         update_sql = """update crawler_chuzu_owner set district_code='{0}' WHERE id={1}""".format(district_code, h[0])
#         service.sql_conn.update(update_sql)
#         service.sql_conn.end()
#         c += 1
#         print('update: {0}'.format(c))
#     service.sql_conn.dispose()
# except:
#     service.sql_conn.dispose()